package com.dingding.api.controller.special;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.dingding.common.core.base.controller.BaseController;
import com.dingding.common.core.base.dto.ResponseEntity;
import com.dingding.common.core.util.JSONUtil;
import com.dingding.facade.account.common.dto.tailwind.ReqAddDepositAccount;
import com.dingding.facade.account.common.dto.tailwind.ReqDeleteDepositAccount;
import com.dingding.facade.account.common.dto.tailwind.ReqGetDepositAccount;
import com.dingding.facade.account.common.dto.tailwind.ReqUAStatus;
import com.dingding.facade.account.common.dto.tailwind.ReqWithdrawals;
import com.dingding.facade.account.facade.tailwind.IDepositAccountFacade;
import com.dingding.facade.user.common.dto.tailwind.ReqForgetDepositPassword;
import com.dingding.facade.user.common.dto.tailwind.ReqUpdateDepositPassword;
import com.dingding.facade.user.facade.tailwind.IDepositPasswordFacade;
import com.dingding.order.service.IUserOrderFacade;
import com.dingding.order.service.special.ISpecialCarOrderFacade;

/**
 * @Description: 专车控制器
 * @author fengshuonan
 * @date 2016年8月18日 下午2:23:07
 * @version 叮叮搭车
 * @since 2.4
 */
@Scope("prototype")
@Controller("specialController")
@RequestMapping("/authorapi/special/passenger/order")
public class SpecialController extends BaseController {

	@Resource(name = "specialCarOrderFacade")
	private ISpecialCarOrderFacade specialCarOrderFacade;

	@Resource(name = "userOrderFacade")
	private IUserOrderFacade userOrderFacade;

	// 顺风车用户账户服务接口
	@Resource(name = "depositAccountFacade_tailwind")
	private IDepositAccountFacade depositAccountFacade;
	
	@Resource(name = "depositPasswordFacade_tailwind")
	private IDepositPasswordFacade depositPasswordFacade;
	
	/**
	 * @Description:实时定位获取专车最快到达时间
	 * @author fengshuonan
	 * @since 2.4
	 */
	@RequestMapping(value = "/v1/boardingTime", method = RequestMethod.POST)
	public void boardingTime(HttpServletRequest request, HttpServletResponse response) {

		String clientData = super.getClientData(request, response);
		String responseData = this.specialCarOrderFacade.boardingTime(clientData);
		super.responseData(response, responseData);
	}

	/**
	 * @Description:去支付
	 * @author fengshuonan
	 * @since 2.4
	 */
	@RequestMapping(value = "/v1/goToPay", method = RequestMethod.POST)
	public void goToPay(HttpServletRequest request, HttpServletResponse response) {

		// 获取客户端数据
		String clientData = super.getClientData(request, response);
		// 执行业务处理，并返回处理后的数据
		String responseData = this.userOrderFacade.goToPay(clientData);
		// 加密数据，并返回给客户端
		super.responseData(response, responseData);
	}

	/**
	 * @Description:专车的乘客支付
	 * @author fengshuonan
	 * @since 2.4
	 */
	@RequestMapping(value = "/v1/specialOrderOnLinePay", method = RequestMethod.POST)
	public void specialOrderOnLinePay(HttpServletRequest request, HttpServletResponse response) {

		// 获取客户端数据
		String clientData = super.getClientData(request, response);
		// 执行业务处理，并返回处理后的数据
		String responseData = this.specialCarOrderFacade.orderPay(clientData);
		// 加密数据，并返回给客户端
		super.responseData(response, responseData);
	}

	/**
	 * @Description:查询支付结果
	 * @author fengshuonan
	 * @since 2.4
	 */
	@RequestMapping(value = "/v1/queryOrderResult", method = RequestMethod.POST)
	public void queryOrderResult(HttpServletRequest request, HttpServletResponse response) {

		String clientData = super.getClientData(request, response);
		String responseData = this.userOrderFacade.queryPayResult(clientData);
		super.responseData(response, responseData);
	}

	/**
	 * @Description:获取乘客进行中订单
	 * @author fengshuonan
	 * @since 2.4
	 */
	@RequestMapping(value = "/v1/makeOrder", method = RequestMethod.POST)
	public void getCustomerUnderWayOrder(HttpServletRequest request, HttpServletResponse response) {

		String clientData = super.getClientData(request, response);
		String responseData = this.specialCarOrderFacade.getCustomerUnderWayOrders(clientData);
		super.responseData(response, responseData);
	}

	/**
	 * @Description:获取乘客的历史订单
	 * @author fengshuonan
	 * @since 2.4
	 */
	@RequestMapping(value = "/v1/historicalOrder", method = RequestMethod.POST)
	public void getHistoryOrder(HttpServletRequest request, HttpServletResponse response) {

		String clientData = super.getClientData(request, response);
		String responseData = this.specialCarOrderFacade.getCustomerHistoryOrders(clientData);
		super.responseData(response, responseData);
	}

	/**
	 * 
	 * @Title: getUDAStatus 
	 * @Description: 获取用户提现认证状态
	 * @author YHQ 
	 * @since V2.6.3
	 * @return void    返回类型
	 * 
	 */
	@RequestMapping(value = "/v1/getUDAStatus", method = RequestMethod.POST)
	public void getUDAStatus(HttpServletRequest request, HttpServletResponse response){
		
		// 客户端请求Bean
		ReqUAStatus reqUAStatus = JSONUtil.getRequestBody(super.getClientData(request, response), ReqUAStatus.class);
		
		// 响应获取用户提现认证状态Bean
		ResponseEntity<Object> responseEntity = depositAccountFacade.getUserAuthenticationStatus(reqUAStatus);
		
		super.responseData(response, JSONUtil.toJSONString(responseEntity));
	}
	
	/**
	 * 
	 * @Title: addDepositAccount 
	 * @Description: 添加顺风车端提现账户
	 * @author YHQ 
	 * @since V2.6.3
	 * @return void    返回类型
	 */
	@RequestMapping(value = "/v1/addDepositAccount", method = RequestMethod.POST)
	public void addDepositAccount(HttpServletRequest request, HttpServletResponse response){
		
		// 添加顺风车端提现账户
		ReqAddDepositAccount reqAddDepositAccount = JSONUtil.getRequestBody(super.getClientData(request, response), ReqAddDepositAccount.class);
		
		// 响应添加顺风车端提现账户Bean
		ResponseEntity<Object> responseEntity = depositAccountFacade.addDepositAccount(reqAddDepositAccount);
		
		super.responseData(response, JSONUtil.toJSONString(responseEntity));
	}
	
	/**
	 * 
	 * @Title: deleteDepositAccount 
	 * @Description: 删除顺风车端提现账户 
	 * @author YHQ 
	 * @since V2.6.3
	 * @return void    返回类型
	 * 
	 */
	@RequestMapping(value = "/v1/deleteDepositAccount", method = RequestMethod.POST)
	public void deleteDepositAccount(HttpServletRequest request, HttpServletResponse response){
		
		// 删除顺风车端提现账户请求Bean
		ReqDeleteDepositAccount reqDeleteDepositAccount = JSONUtil.getRequestBody(super.getClientData(request, response), ReqDeleteDepositAccount.class);
		
		// 删除顺风车端提现账户 
		ResponseEntity<Object> responseEntity = depositAccountFacade.deleteDepositAccount(reqDeleteDepositAccount);
		
		// 响应删除顺风车端提现账户Bean
		super.responseData(response, JSONUtil.toJSONString(responseEntity));
	}
	
	/**
	 * 
	 * @Title: getDepositAccountList 
	 * @Description: 获取顺风车端的提现账户列表
	 * @author YHQ 
	 * @since V2.6.3
	 * @return void    返回类型
	 * 
	 */
	@RequestMapping(value = "/v1/getDepositAccountList", method = RequestMethod.POST)
	public void getDepositAccountList(HttpServletRequest request, HttpServletResponse response){
		
		// 获取顺风车端的提现账户列表请求Bean
		ReqGetDepositAccount reqGetDepositAccount = JSONUtil.getRequestBody(super.getClientData(request, response), ReqGetDepositAccount.class);
		
		// 获取顺风车端的提现账户列表
		ResponseEntity<Object> responseEntity = depositAccountFacade.getDepositAccountList(reqGetDepositAccount);
		
		super.responseData(response, JSONUtil.toJSONString(responseEntity));
	}
	
	/**
	 * 
	 * @Title: updateUserDepositPassword 
	 * @Description: 修改用户提现密码(乘客端)
	 * @author YHQ 
	 * @since V2.6.3
	 * @return void    返回类型
	 * 
	 */
	@RequestMapping(value = "/v1/updateUserDepositPassword", method = RequestMethod.POST)
	public void updateUserDepositPassword(HttpServletRequest request, HttpServletResponse response){
		
		ReqUpdateDepositPassword reqUpdateDepositPassword = JSONUtil.getRequestBody(super.getClientData(request, response), ReqUpdateDepositPassword.class);
		
		ResponseEntity<Object> responseEntity = depositPasswordFacade.updateUserDepositPassword(reqUpdateDepositPassword);
		
		super.responseData(response, JSONUtil.toJSONString(responseEntity));
	}
	
	/**
	 * 
	 * @Title: forgetDepositPassword 
	 * @Description: 忘记提现密码(乘客端) 
	 * @author YHQ 
	 * @since V2.6.3
	 * @return void    返回类型
	 * 
	 */
	@RequestMapping(value = "/v1/forgetDepositPassword", method = RequestMethod.POST)
	public void forgetDepositPassword(HttpServletRequest request, HttpServletResponse response){
		
		ReqForgetDepositPassword reqForgetDepositPassword = JSONUtil.getRequestBody(super.getClientData(request, response), ReqForgetDepositPassword.class);
		
		ResponseEntity<Object> responseEntity = depositPasswordFacade.forgetDepositPassword(reqForgetDepositPassword);
		
		super.responseData(response, JSONUtil.toJSONString(responseEntity));
	}
	
	/**
	 * 
	 * @Title: tailwindUserDeposit 
	 * @Description: 顺风车用户提现
	 * @author YHQ 
	 * @since V2.6.3
	 * @return void    返回类型
	 */
	@RequestMapping(value = "/v1/tailwindUserDeposit", method = RequestMethod.POST)
	public void tailwindUserDeposit(HttpServletRequest request, HttpServletResponse response){
		
		ReqWithdrawals reqWithdrawals = JSONUtil.getRequestBody(super.getClientData(request, response), ReqWithdrawals.class);
		
		ResponseEntity<Object> responseEntity = depositAccountFacade.withdrawals(reqWithdrawals);
		
		super.responseData(response, JSONUtil.toJSONString(responseEntity));
	}
	
}